package com.woniuxy.utils;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

/**
 * @BelongsProject: java-85-course-code
 * @BelongsPackage: com.woniuxy.utils
 * @Author: LiTongMiao
 * @Date: 2022/2/15 12:11
 * @Description: TODO
 */
@WebFilter(urlPatterns = "/*",filterName = "timeFilter")
public class TimeFilter implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        Filter.super.init(filterConfig);
    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        long startTime=System.currentTimeMillis();
        chain.doFilter(request, response);
        System.out.println("请求耗时"+(System.currentTimeMillis() - startTime)+"ms");

    }

    @Override
    public void destroy() {
        Filter.super.destroy();
    }
}
